package com.etc.library.util;

import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
public class ResultBody {

    private String code;
    private String message;
    private Object data;


    public static ResultBody success(){
        ResultBody body = new ResultBody();
        return body.setCode(ResultBodyEnum.SUCCESS.getCode()).setMessage(ResultBodyEnum.SUCCESS.getMessage());
    }
    public static ResultBody success(Object data){
        ResultBody body = new ResultBody();
        return body.setCode(ResultBodyEnum.SUCCESS.getCode()).setMessage(ResultBodyEnum.SUCCESS.getMessage()).setData(data);
    }

    public static ResultBody success(String message){
        ResultBody body = new ResultBody();
        return body.setCode(ResultBodyEnum.SUCCESS.getCode()).setMessage(message);
    }
    public static ResultBody success(String message,Object data){
        ResultBody body = new ResultBody();
        return body.setCode(ResultBodyEnum.SUCCESS.getCode()).setMessage(message).setData(data);
    }

    public static ResultBody error(){
        ResultBody body = new ResultBody();
        return body.setCode(ResultBodyEnum.ERROR.getCode()).setMessage(ResultBodyEnum.ERROR.getMessage());
    }
    public static ResultBody error(String message){
        ResultBody body = new ResultBody();
        return body.setCode(ResultBodyEnum.ERROR.getCode()).setMessage(message);
    }

}
